<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>
        SpringToolSuite快速创建一个springboot项目 - seventeenw的博客
      </title>
    <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  
  <meta name="theme-color" content="#000000" />
  
  <meta http-equiv="window-target" content="_top" />
  
  
  <meta name="description" content="首先下载一个专为Spring设计的eclipse版本——sts，官网链接：Spring tool suite 4，这个IDE和eclipse非常相似，下载解压后" />
  <meta name="generator" content="Hugo 0.59.1 with theme pure" />
  <title>SpringToolSuite快速创建一个springboot项目 - seventeenw的博客</title>
  

  <link rel="stylesheet" href="https://seventeenw.gitee.io/blogs/css/style.css">
  <link rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/9.15.10/styles/github.min.css">
  <meta property="og:title" content="SpringToolSuite快速创建一个springboot项目" />
<meta property="og:description" content="首先下载一个专为Spring设计的eclipse版本——sts，官网链接：Spring tool suite 4，这个IDE和eclipse非常相似，下载解压后" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://seventeenw.gitee.io/blogs/2019/11/springtoolsuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE-%E5%89%AF%E6%9C%AC/" />
<meta property="article:published_time" content="2019-11-19T14:05:58+08:00" />
<meta property="article:modified_time" content="2019-11-19T14:05:58+08:00" />
<meta itemprop="name" content="SpringToolSuite快速创建一个springboot项目">
<meta itemprop="description" content="首先下载一个专为Spring设计的eclipse版本——sts，官网链接：Spring tool suite 4，这个IDE和eclipse非常相似，下载解压后">


<meta itemprop="datePublished" content="2019-11-19T14:05:58&#43;08:00" />
<meta itemprop="dateModified" content="2019-11-19T14:05:58&#43;08:00" />
<meta itemprop="wordCount" content="1046">



<meta itemprop="keywords" content="" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="SpringToolSuite快速创建一个springboot项目"/>
<meta name="twitter:description" content="首先下载一个专为Spring设计的eclipse版本——sts，官网链接：Spring tool suite 4，这个IDE和eclipse非常相似，下载解压后"/>

  <!--[if lte IE 9]>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
    <![endif]-->

  <!--[if lt IE 9]>
      <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->

</head>
  </head>
  <body class="main-center theme-black" itemscope itemtype="http://schema.org/WebPage"><header class="header" itemscope itemtype="http://schema.org/WPHeader">
    <div class="slimContent">
      <div class="navbar-header">
        <div class="profile-block text-center">
          <a id="avatar" href="https://github.com/wengshiquan" target="_blank">
            <img class="img-circle img-rotate" src="https://seventeenw.gitee.io/blogs/avatar.png" width="200" height="200">
          </a>
          <h2 id="name" class="hidden-xs hidden-sm">17Null</h2>
          <h3 id="title" class="hidden-xs hidden-sm hidden-md">Java Developer</h3>
          <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i>Fuzhou, China</small>
        </div><div class="search" id="search-form-wrap">
    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="搜索" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i
                        class="icon icon-search"></i></button>
            </span>
        </div>
        <div class="ins-search">
            <div class="ins-search-mask"></div>
            <div class="ins-search-container">
                <div class="ins-input-wrapper">
                    <input type="text" class="ins-search-input" placeholder="想要查找什么..."
                        x-webkit-speech />
                    <button type="button" class="close ins-close ins-selectable" data-dismiss="modal"
                        aria-label="Close"><span aria-hidden="true">×</span></button>
                </div>
                <div class="ins-section-wrapper">
                    <div class="ins-section-container"></div>
                </div>
            </div>
        </div>
    </form>
</div>
        <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
        <ul class="nav navbar-nav main-nav">
            <li class="menu-item menu-item-home">
                <a href="/blogs/">
                    <i class="icon icon-home-fill"></i>
                  <span class="menu-title">主页</span>
                </a>
            </li>
            <li class="menu-item menu-item-reprint">
                <a href="/blogs/reprint">
                    <i class="icon icon-star-fill"></i>
                  <span class="menu-title">转载</span>
                </a>
            </li>
            <li class="menu-item menu-item-about">
                <a href="/blogs/about">
                    <i class="icon icon-cup-fill"></i>
                  <span class="menu-title">关于</span>
                </a>
            </li>
        </ul>
      </nav>
    </div>
  </header>
  <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">公告</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content"><p>一直想做前端的java程序员~</p>
            </div>
        </div>
    </div>
</div>

      <div class="widget">
    <h3 class="widget-title"> 分类</h3>
    <div class="widget-body">
        <ul class="category-list">
        </ul>
    </div>
</div>
      <div class="widget">
    <h3 class="widget-title"> 标签</h3>
    <div class="widget-body">
        <ul class="tag-list">
            
        </ul>

    </div>
</div>
      
<div class="widget">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget-body">
        <ul class="recent-post-list list-unstyled no-thumbnail">
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/vue-element-template-%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E7%9A%84%E5%BC%80%E5%8F%91%E6%B5%81%E7%A8%8B/" class="title">vue-element-template 从零开始的开发流程</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-25 22:51:58 &#43;0800 CST" itemprop="datePublished">2020-06-25</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/vue-element-template-%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E7%9A%84%E5%BC%80%E5%8F%91%E6%97%A5%E5%BF%97/" class="title">vue-element-template 从零开始的开发日志</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-25 22:49:21 &#43;0800 CST" itemprop="datePublished">2020-06-25</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/idea-springboot%E5%9B%BE%E6%A0%87%E4%B8%8D%E6%AD%A3%E7%A1%AE/" class="title">IDEA Springboot图标不正确</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-25 15:06:28 &#43;0800 CST" itemprop="datePublished">2020-06-25</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/%E6%A0%B9%E6%8D%AE%E6%95%B0%E6%8D%AE%E5%BA%93%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E5%AE%9E%E4%BD%93%E7%B1%BB%E7%AD%89%E6%96%87%E4%BB%B6/" class="title">根据数据库自动生成实体类等文件</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-10 11:07:41 &#43;0800 CST" itemprop="datePublished">2020-06-10</time>
                    </p>
                </div>
            </li>
            <li>
                <div class="item-inner">
                    <p class="item-title">
                        <a href="https://seventeenw.gitee.io/blogs/2020/06/springboot-quartz%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E8%A7%A3%E5%86%B3%E6%97%A0%E6%B3%95%E6%B3%A8%E5%85%A5%E5%8F%8A%E6%8C%81%E4%B9%85%E5%8C%96%E7%9A%84%E9%97%AE%E9%A2%98/" class="title">springboot&#43;quartz定时任务（解决无法注入bean及持久化的问题）</a>
                    </p>
                    <p class="item-date">
                        <time datetime="2020-06-05 00:09:03 &#43;0800 CST" itemprop="datePublished">2020-06-05</time>
                    </p>
                </div>
            </li>
        </ul>
    </div>
</div>
  </div>
</aside>

    
    
  <aside class="sidebar sidebar-toc collapse" id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
    <div class="slimContent">
      <nav id="toc" class="article-toc">
        <h3 class="toc-title">文章目录</h3>
        <div class="toc-content always-active"><nav id="TableOfContents">
<ul>
<li>
<ul>
<li>
<ul>
<li>
<ul>
<li><a href="#开始创建项目-本篇讲述从sts直接创建项目">开始创建项目，本篇讲述从STS直接创建项目</a>
<ul>
<li><a href="#new-spring-starter-project">new——&gt;Spring Starter Project</a></li>
<li><a href="#接着-name填入项目名称-group随意-其他的不用管-这里的service-url指spring-boot官网地址">接着，name填入项目名称，group随意，其他的不用管，这里的service URL指Spring boot官网地址。</a></li>
<li><a href="#next-version选择1-5-11-如果是2-0以上的也可以-available中输入查找web选择和devtools选项-选中">next，version选择1.5.11（如果是2.0以上的也可以），Available中输入查找web选择和DevTools选项，选中。</a></li>
<li><a href="#点击next-finish均可-项目创建完毕-目录如下">点击next/finish均可，项目创建完毕，目录如下：</a></li>
<li><a href="#写一个简单的示例">写一个简单的示例</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</nav>
        </div>
      </nav>
    </div>
  </aside>
<main class="main" role="main"><div class="content">
  <article id="-" class="article article-type-" itemscope
    itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      <h1 itemprop="name">
  <a
    class="article-title"
    href="/blogs/2019/11/springtoolsuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE-%E5%89%AF%E6%9C%AC/"
    >SpringToolSuite快速创建一个springboot项目</a
  >
</h1>

      <div class="article-meta">
        <span class="article-date">
  <i class="icon icon-calendar-check"></i>
<a href="https://seventeenw.gitee.io/blogs/2019/11/springtoolsuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE-%E5%89%AF%E6%9C%AC/" class="article-date">
  <time datetime="2019-11-19 14:05:58 &#43;0800 CST" itemprop="datePublished">2019-11-19</time>
</a>
</span>

        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/blogs/2019/11/springtoolsuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE-%E5%89%AF%E6%9C%AC/#comments"
            class="article-comment-link">评论</a></span>
		<span class="post-wordcount hidden-xs" itemprop="wordCount">字数统计:1046字</span>
		<span class="post-readcount hidden-xs" itemprop="timeRequired">阅读时长:3分 </span>
      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      

<p>首先下载一个专为Spring设计的eclipse版本——sts，官网链接：<a href="https://spring.io/tools">Spring tool suite 4</a>，这个IDE和eclipse非常相似，下载解压后可以直接运行；</p>

<h4 id="开始创建项目-本篇讲述从sts直接创建项目">开始创建项目，本篇讲述从STS直接创建项目</h4>

<h5 id="new-spring-starter-project">new——&gt;Spring Starter Project</h5>

<p><img src="https://gitee.com/w17null/imgs/raw/master/blog/001-SpringToolSuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE/001-01.png" alt="001-01.png" style="zoom: 33%;" /></p>

<h5 id="接着-name填入项目名称-group随意-其他的不用管-这里的service-url指spring-boot官网地址">接着，name填入项目名称，group随意，其他的不用管，这里的service URL指Spring boot官网地址。</h5>

<p><img src="https://github.com/wengshiquan/imgs/blob/master/blog/001-SpringToolSuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE/001-02.png?raw=true" alt="001-02.png" style="zoom: 50%;" /></p>

<h5 id="next-version选择1-5-11-如果是2-0以上的也可以-available中输入查找web选择和devtools选项-选中">next，version选择1.5.11（如果是2.0以上的也可以），Available中输入查找web选择和DevTools选项，选中。</h5>

<p><img src="https://github.com/wengshiquan/imgs/blob/master/blog/001-SpringToolSuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE/001-03.png?raw=true" alt="001-03.png" style="zoom: 50%;" /></p>

<h5 id="点击next-finish均可-项目创建完毕-目录如下">点击next/finish均可，项目创建完毕，目录如下：</h5>

<p><img src="https://github.com/wengshiquan/imgs/blob/master/blog/001-SpringToolSuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE/001-04.png?raw=true" alt="001-04.png" style="zoom: 67%;" /></p>

<p>这个目录结构与eclipse中建立的maven项目基本一致。</p>

<p>注意：</p>

<p>项目创建过程中，会发现首次使用maven的时候从中央仓库下载jar包非常慢，这里可以使用阿里提供的镜像。找到STS/项目使用的maven的setting.xml文件，在其中的<mirrors>中添加如下代码：</p>

<pre><code>&lt;mirror&gt;

   &lt;id&gt;alimaven&lt;/id&gt;

   &lt;name&gt;aliyun maven&lt;/name&gt;

   &lt;url&gt;http://maven.aliyun.com/nexus/content/groups/public/&lt;/url&gt;

   &lt;mirrorOf&gt;central&lt;/mirrorOf&gt;    

  &lt;/mirror&gt;
</code></pre>

<p>这个代码的意思是指定从阿里的镜像仓库下载jar包，配置完毕后重新创建项目即可。</p>

<h5 id="写一个简单的示例">写一个简单的示例</h5>

<pre><code>SpringBoot项目创建好了，但是这个项目怎么用呢，它好像和之前接触的项目结构不大一样。下面讲述一个简单的实现前端请求与后端返回页面的功能示例；  
</code></pre>

<p>在src/man/java中创建如下Controller类：</p>

<p><img src="https://github.com/wengshiquan/imgs/blob/master/blog/001-SpringToolSuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE/001-05.png?raw=true" alt="001-05.png" /></p>

<pre><code>package com.example.demo.controller;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
 
@Controller //标识一个控制器 接收用户请求,RestController=Controller+ResponseBody
public class TestController {
	
	@RequestMapping(&quot;/index.do&quot;)//HTTP请求
	public String test() {
		System.out.println(&quot;TestController&gt;&gt;&gt;test&gt;&gt;&gt;is running....return a string&quot;);
		return &quot;index&quot;;//返回一个视图（HTML页面）
	}
}
</code></pre>

<p>在src/man/resources中的template文件夹下创建一个index.html（注意SpringBoot默认是不支持jsp的）</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=&quot;UTF-8&quot; /&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  hello,this is index.html2...
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>跟着，为了使得SpringBoot能够返回前端界面，需要在pom.xml中添加一个依赖。</p>

<pre><code>&lt;dependency&gt;
		  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
		  &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
		  &lt;scope&gt;&lt;/scope&gt;
&lt;/dependency&gt;
</code></pre>

<p>然后，我们可以在src/main/resouces中创建一个配置文件application.properties，说明如代码所示。</p>

<pre><code>#server config
#快捷键 crtl + /
#配置服务器
 
#端口
server.port=80
#上下文访问路径
server.servlet.context-path=/test
</code></pre>

<p>下面点击项目run as——&gt;Spring Boot App，在浏览器中输入localhost:80/test/index.do，就会跳出index.html的内容。</p>

<p><img src="https://github.com/wengshiquan/imgs/blob/master/blog/001-SpringToolSuite%E5%BF%AB%E9%80%9F%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAspringboot%E9%A1%B9%E7%9B%AE/001-06.png?raw=true" alt="001-06.png" style="zoom:50%;" /></p>

<p>ok，一个简单的SpringBoot项目示例写好了</p>

    </div>
  </article>
<section id="comments">
</section>

</div><nav class="bar bar-footer clearfix" data-stick-bottom>
    <div class="bar-inner">
        <ul class="pager pull-left">
            <li class="prev">
                <a href="https://seventeenw.gitee.io/blogs/about/" title="关于自己"><i
                        class="icon icon-angle-left"
                        aria-hidden="true"></i><span>&nbsp;&nbsp;上一篇</span></a>
            </li>
            <li class="next">
                <a href="https://seventeenw.gitee.io/blogs/2019/11/eclipse%E5%88%9D%E5%A7%8B%E5%8C%96%E9%85%8D%E7%BD%AE/"
                    title="Eclipse初始化配置"><span>下一篇&nbsp;&nbsp;</span><i
                        class="icon icon-angle-right" aria-hidden="true"></i></a>
            </li>
            
            <li class="toggle-toc">
                <a class="toggle-btn collapsed" data-toggle="collapse" href="#collapseToc" aria-expanded="false"
                    title="文章目录" role="button">
                    <span>[&nbsp;</span><span>文章目录</span>
                    <i class="text-collapsed icon icon-anchor"></i>
                    <i class="text-in icon icon-close"></i>
                    <span>]</span>
                </a>
            </li>
        </ul>
        <div class="bar-right">
            <div class="share-component" data-sites="weibo,qq,wechat,facebook,twitter"
                data-mobile-sites="weibo,qq,qzone"></div>
        </div>
    </div>
</nav>
</main><footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
<ul class="social-links">
    <li><a href="https://github.com/wengshiquan" target="_blank" title="github" data-toggle=tooltip data-placement=top >
            <i class="icon icon-github"></i></a></li>
    <li><a href="https://seventeenw.gitee.io/index.xml" target="_blank" title="rss" data-toggle=tooltip data-placement=top >
            <i class="icon icon-rss"></i></a></li>
    <li><a href="https://gitee.com/seventeenw" target="_blank" title="tags" data-toggle=tooltip data-placement=top >
            <i class="icon icon-tags"></i></a></li>
</ul>
  <div class="copyright">
    &copy;2017  -
    2020
    <div class="publishby">
        Theme by <a href="https://github.com/xiaoheiAh" target="_blank"> xiaoheiAh </a>base on<a href="https://github.com/xiaoheiAh/hugo-theme-pure" target="_blank"> pure</a>.
    </div>
  </div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
   window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/highlight.min.js"></script>
<script type="text/javascript" src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/rust.min.js"></script>
<script type="text/javascript"
   src="https://cdn.staticfile.org/highlight.js/9.15.10/languages/dockerfile.min.js"></script>
<script>
hljs.configure({
  tabReplace: '    ', 
  classPrefix: ''     
                      
})
hljs.initHighlightingOnLoad();
</script>
<script type="text/javascript" src="https://seventeenw.gitee.io/blogs/js/application.js"></script>
<script type="text/javascript" src="https://seventeenw.gitee.io/blogs/js/plugin.js"></script>
<script>
      (function (window) {
          var INSIGHT_CONFIG = {
              TRANSLATION: {
                  POSTS: '文章',
                  PAGES: '页面',
                  CATEGORIES: '分类',
                  TAGS: '标签',
                  UNTITLED: '(未命名)',
              },
              ROOT_URL: 'https:\/\/seventeenw.gitee.io\/blogs',
              CONTENT_URL: 'https:\/\/seventeenw.gitee.io\/blogs\/searchindex.json ',
          };
          window.INSIGHT_CONFIG = INSIGHT_CONFIG;
      })(window);
      </script>
<script type="text/javascript" src="https://seventeenw.gitee.io/blogs/js/insight.js"></script>

  </body>
</html>
